

<!DOCTYPE HTML><html lang="zh-CN">
<head><meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
	<title>iOS证书签名机制&amp;重签名&amp;防止重签名-转载-素问</title>
	<meta name="msapplication-TileColor" content="#009a61"/>
<link rel="stylesheet" href="http://suwenclub.cn/zb_users/theme/ydgreen/style/style.css"/>
<link rel="stylesheet" href="http://suwenclub.cn/zb_users/theme/ydgreen/style/css/blog_all.css"/>
<link rel="stylesheet" href="http://suwenclub.cn/zb_users/theme/ydgreen/style/css/responsive.css"/>
<!--[if lt IE 9]><link rel="stylesheet" href="http://suwenclub.cn/zb_users/theme/ydgreen/style/css/ie.css"/>
<script src="http://suwenclub.cn/zb_users/theme/ydgreen/style/js/html5shiv.js"></script>
<script src="http://suwenclub.cn/zb_users/theme/ydgreen/style/js/respond.js"></script>
<![endif]-->
<script src="http://suwenclub.cn/zb_system/script/common.js" type="text/javascript"></script>
<script src="http://suwenclub.cn/zb_system/script/c_html_js_add.php" type="text/javascript"></script>
<script src="http://suwenclub.cn/zb_users/theme/ydgreen/style/js/debug.js"></script>
<script data-ad-client="ca-pub-8603941876586276" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!--这是单行注释-->
<!--<script data-ad-client="ca-pub-2176327711001633" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>-->
<style type="text/css">
.global-navTags{background-color: #005f3c;}
.global-navTags nav .nav__item--more{background-color: #005f3c}
.global-navTags nav .nav__item--more:before{background-image: -webkit-linear-gradient(0deg, rgba(0,95,60,0), #005f3c);
background-image: linear-gradient(90deg, rgba(0,95,60,0), #005f3c)}
.global-navTags .tag-mgr__box{background-color: #005f3c;}

</style>

</head>
<body class="blog-post">

<!--[if lt IE 9]><div class="alert alert-danger topframe" role="alert">你的浏览器实在<strong>太太太太太太旧了</strong>，放学别走，升级完浏览器再说 <a target="_blank" class="alert-link" href="http://browsehappy.com">立即升级</a></div><![endif]-->

<div class="global-nav">
	<nav class="container nav">
		<div class="dropdown m-menu">
			<a href="javascript:void(0);" id="dLabel" class="visible-xs-block m-toptools" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				<span class="glyphicon glyphicon-align-justify"></span>
				<span class="mobile-menu__unreadpoint"></span>
			</a>
			<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
				<li id="nvabar-item-index"><a href="http://suwenclub.cn/">首页</a></li><li id="navbar-page-2"><a href="http://suwenclub.cn/?id=2">留言本</a></li><li id="navbar-page-3"><a href="http://suwenclub.cn/?id=3">历史上的今天</a></li>			</ul>
		</div>
		<h1 class="logo"><a class="sf" href="http://suwenclub.cn/">素问</a></h1>
		<a href="http://suwenclub.cn/zb_system/login.php" class="visible-xs-block pull-right m-ask m-toptools">
			<span class="glyphicon glyphicon-pencil"></span>
		</a>
		<ul class="menu list-inline pull-left pull-left-nav hidden-xs">
			<li id="nvabar-item-index"><a href="http://suwenclub.cn/">首页</a></li><li id="navbar-page-2"><a href="http://suwenclub.cn/?id=2">留言本</a></li><li id="navbar-page-3"><a href="http://suwenclub.cn/?id=3">历史上的今天</a></li>		</ul>
		
		
		<ul class="opts pull-right list-inline hidden-xs">

			<li class="opts__item user dropdown hoverDropdown">
								<a href="http://suwenclub.cn/zb_system/login.php" rel="nofollow" class="dropdownBtn user-avatar" data-toggle="dropdown" style="background-image: url('http://suwenclub.cn/zb_users/theme/ydgreen/style/images/user-64.png')"></a>
								<ul class="dropdown-menu dropdown-menu-right">
								<li><a href="http://suwenclub.cn/zb_system/login.php" title="登陆" rel="nofollow">登陆</a></li>
								</ul>
			</li>
		</ul>
		<form action="http://suwenclub.cn/search.php?act=search" class="header-search pull-right hidden-sm hidden-xs">
			<button class="btn btn-link">
				<span class="sr-only">搜索</span>
				<span class="glyphicon glyphicon-search"></span>
			</button>
			<input id="searchBox" name="q" type="text" placeholder="输入关键字搜索" class="form-control"value=""/>
		</form>

	</nav>
</div>


<div class="global-navTags">
	<div class="container">
		<nav class=" nav">
			<ul class="nav__list">
				<li class="nav__item"><a href="http://suwenclub.cn/"><i class="fa fa-home"></i>首页</a></li>
				<li class="nav__item"><a href="http://suwenclub.cn/feed.php" target="_blank"><i class="fa fa-list-alt"></i>feed</a></li>
				<li class="nav__item nav__item--split"><a><span class="split"></span></a></li>
										 <li class="nav__item tag-nav__item"><a href="http://suwenclub.cn/?tags=1" title="1个话题"> 移动开发 </a></li> <li class="nav__item tag-nav__item"><a href="http://suwenclub.cn/?tags=2" title="1个话题"> Flutter </a></li>									<li class="nav__item nav__item--more" data-open="0">
					<a class="nav__item--more-link">
						<div class="tag__more"><i class="tag__more--icon"></i><i class="tag__more--icon"></i><i class="tag__more--icon"></i></div>
					</a>
				</li>
			</ul>
			
		</nav>
	</div>
</div>    <div class="wrap">
    <div class="post-topheader custom-">
        <div class="container">
            <div class="row">
                <div class="col-md-9 col-sm-8 col-xs-12">
                    <h1 class="h3 title clearfix" id="articleTitle">
                        <!--<span class="article__title--icon-symbol mb10">文</span>-->
                        <a href="http://suwenclub.cn/?id=21" title="iOS证书签名机制&amp;重签名&amp;防止重签名"> iOS证书签名机制&amp;重签名&amp;防止重签名</a>
                    </h1>
                    <div class="author">
												<a href="http://suwenclub.cn/?cate=2" class="mr5 ml15"><strong>转载</strong></a>
					</div>
                </div>

            </div>
        </div>
    </div><!-- end .post-topheader -->

    <div class="container mt30">
        <div class="row">
            <div class="col-xs-12 col-md-9 main ">
				<div class="article fmt article__content">
										<h2 data-id="heading-0" id="cocoachina0" style="box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">iOS签名机制</h2><h3 data-id="heading-1" id="cocoachina1" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">概念</h3><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">相比安卓系统随便从哪里下载都能运行，系统安全存在许多隐患，例如盗版软件、病毒入侵、静默安装等等。苹果为了控制手机上的所有应用必须是经过授权的，规定正规应用只能在AppStore下载，同时对于调试阶段的安装、灰度测试和企业分发，苹果使用双重签名机制来控制应用权限并使其不被滥用。先介绍一些概念便于后续的理解。</p><h4 data-id="heading-2" id="cocoachina2" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);">非对称加密</h4><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">非对称加密则两份密钥，分别是公钥和私钥，用公钥加密的数据，要用私钥才能解密，用私钥加密的数据，要用公钥才能解密。正常情况下，公钥可以对外公开，而私钥需私密保存。我们常用<span style="box-sizing: border-box; font-weight: 700;">公钥加密私钥解密</span>的方式来进行加密防止数据明文传输，用<span style="box-sizing: border-box; font-weight: 700;">私钥加密公钥解密</span>的方式来签名确保数据的完整性防止被篡改。</p><h4 data-id="heading-3" id="cocoachina3" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);">数字摘要</h4><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">将任意长度的源文本通过Hash函数计算得到一窜固定长度的文本，要保证不同源文本计算得到的值各不相同，且不能被反推得到源文本。常用的Hash算法有MD5和SHA。</p><h4 data-id="heading-4" id="cocoachina4" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);">数字签名</h4><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">又称公钥数字签名，是非对称加密与数字摘要的结合，用于验证数据的完整性及不可抵赖性。发送方用接收方的公钥对摘要进行加密后和报文一起发送，接受方接受后用相同的Hash算法对报文进行摘要计算，接着用自己的私钥解密得到发送方的摘要，如果两个摘要相同则接收方就能确认该报文是对方发出的且未被篡改。</p><h4 data-id="heading-5" id="cocoachina5" style="box-sizing: border-box; margin-top: 10px; margin-bottom: 10px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);">其他</h4><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><img src="http://api.cocoachina.com/uploads//20191211/1576049725126335.png" title="1576049725126335.png" alt="image.png" data-bd-imgshare-binded="1" data-isloading="1" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;"/></p><h3 data-id="heading-6" id="cocoachina6" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">AppStore签名</h3><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">将App提交审核后，苹果会用官方的私钥对我们提交的App重签名，用户下载到手机后，iOS设备内置的公钥会对App进行验证，验证成功即可正常使用。<br style="box-sizing: border-box;"/>所以App上传到AppStore后，就跟我们本地的证书/Provisioning Profile 都没有关系了，无论是否过期或被废除，都不会影响 AppStore 上的安装包。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p><figure style="box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);"><img src="http://api.cocoachina.com/uploads//20191211/1576049732640575.png" title="1576049732640575.png" alt="image.png" data-bd-imgshare-binded="1" data-isloading="1" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;"/><figcaption style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></figcaption></figure></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><h3 data-id="heading-7" id="cocoachina7" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">Xcode安装&amp;Adhoc&amp;In-House</h3><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">对于非AppStore安装的应用苹果采用了双重签名的方式，用到了两对密钥，Mac电脑密钥对L，苹果官方密钥对A。</p><ul class=" list-paddingleft-2" style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);"><li><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;">我们在进行开发时，会从Mac的keychain 里的 “从证书颁发机构请求证书生成”CertificateSigningRequest(含有Mac的公钥L信息)文件上传到苹果后台，苹果会用其私钥A对公钥L签名，并生成一份包含公钥L信息和苹果签名信息的开发/发布证书cer，当我们将cer下载到Mac后，keychain会把CertificateSigningRequest和证书关联起来。</p></li><li><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;">在苹果后台配置AppID,可用设备IDs(企业证书不需要)和Entitlements,用这些额外信息和证书再用私钥A签名，最后苹果将证书+额外信息+签名组成一个Provisioning Profile文件(mobileprovision后缀)，下载到Mac上。</p></li><li><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;">在Mac上编译完一个App后，Mac会用私钥L对App签名，并将Provisioning Profile文件也打包到App中，文件名为 embedded.mobileprovision。</p></li><li><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;">安装时，苹果通过内置在手机中的公钥A验证embedded.mobileprovision中的签名是否正确，接着验证证书中的签名是否正确。</p></li><li><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; line-height: 30px; overflow-wrap: break-word;">确保了 embedded.mobileprovision 里的数据都是苹果授权以后，就可以取出里面的数据，做各种验证，包括用公钥 L 验证APP签名，验证设备 ID 是否在 ID 列表上，验证证书是否过期，AppID 是否对应得上，权限开关是否跟 APP 里的 Entitlements 对应等等。</p></li></ul><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">如果别的 Mac 也要编译签名这个 App，可以将私钥导出给其他 Mac 用，在 keychain 里导出私钥，就会存成.p12 文件，其他 Mac 导入了这个私钥后便可用同一套苹果证书及Provisioning Profile文件。 In-House安装不限制设备ID数。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p><figure style="box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);"><img src="http://api.cocoachina.com/uploads//20191211/1576049745202896.png" title="1576049745202896.png" alt="image.png" data-bd-imgshare-binded="1" data-isloading="1" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;"/><figcaption style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></figcaption></figure></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><h2 data-id="heading-8" id="cocoachina8" style="box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">重签名</h2><h3 data-id="heading-9" id="cocoachina9" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">完全重签名</h3><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">重签是把已发布/未发布的包重新签名为自己的证书和签名，关键就是替换ipa内的证书和描述文件。主要通过<span style="box-sizing: border-box; font-weight: 700;">codesign</span>命令完成。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">0 查看ipa包是否加壳，只有未加壳的包才可以重签名。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">$&nbsp;otool&nbsp;-l&nbsp;「Mach-O文件」&nbsp;|&nbsp;grep&nbsp;crypt
//&nbsp;输出cryptid为0代表已经砸壳，即解密，为1或者2表示以第1类或者第2类加密方案加密。复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">1.1 查看本地证书列表并记录下要用来签名的证书名，例如&quot;iPhone Distribution: XXXXX (XXX)&quot;。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">$&nbsp;security&nbsp;find-identity&nbsp;-v&nbsp;-p&nbsp;codesigning复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">1.2 新建Xcode工程，用1.1证书编译后生成新App，将App包里<code style="box-sizing: border-box;">embedded.mobileprovision</code>文件取出替换ipa包中的文件。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">2.1 删除ipa包内部可被重签名的插件（PlugIns目录下）。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">2.2 将ipa包内的所有Framework重签名（Frameworks目录下）。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">$&nbsp;codesign&nbsp;-fs&nbsp;&quot;iPhone&nbsp;Distribution:&nbsp;XXXXX&nbsp;(XXX)&quot;&nbsp;&nbsp;xxx.framework复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">2.3 查看Mach-O文件是否有系统权限，若没有则添加权限。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">$&nbsp;chmod&nbsp;+x&nbsp;「Mach-O文件」复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">3.1 将ipa包内info.plist的BundleId修改为1.1中工程的BundleId。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">3.2 用命令查看embedded.mobileprovision文件，找到其中的entitlements字段，并且复制entitlements字段和其中的内容。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">$&nbsp;security&nbsp;cms&nbsp;-D&nbsp;-i&nbsp;「embedded文件路径」复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">3.3 新建entitlements.plist文件，将复制内容拷贝到文件中，然后将entitlements.plist复制到ipa的同级目录下。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">3.4 对App进行重签名，并压缩成新的ipa包。</p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">//重签名
$&nbsp;codesign&nbsp;-fs&nbsp;&quot;iPhone&nbsp;Distribution:&nbsp;XXXXX&nbsp;(XXX)&quot;&nbsp;--no-strict&nbsp;--entitlements=entitlements.plist

//压缩ipa包
$&nbsp;zip&nbsp;-r&nbsp;「输出的文件名(.ipa)」&nbsp;Payload/复制代码</pre><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">4 将ipa包安装到手机，若能同时存在两个应用且能正常运行则表示重签名成功。</p><h3 data-id="heading-10" id="cocoachina10" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">Shell脚本重签名</h3><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">#&nbsp;${SRCROOT}&nbsp;它是工程文件所在的目录
TEMP_PATH=&quot;${SRCROOT}/Temp&quot;
#资源文件夹，我们提前在工程目录下新建一个APP文件夹，里面放ipa包
ASSETS_PATH=&quot;${SRCROOT}/APP&quot;
#目标ipa包路径
TARGET_IPA_PATH=&quot;${ASSETS_PATH}/*.ipa&quot;
#清空Temp文件夹
rm&nbsp;-rf&nbsp;&quot;${SRCROOT}/Temp&quot;
mkdir&nbsp;-p&nbsp;&quot;${SRCROOT}/Temp&quot;

#----------------------------------------
#&nbsp;1.&nbsp;解压IPA到Temp下
unzip&nbsp;-oqq&nbsp;&quot;$TARGET_IPA_PATH&quot;&nbsp;-d&nbsp;&quot;$TEMP_PATH&quot;
#&nbsp;拿到解压的临时的APP的路径
TEMP_APP_PATH=$(set&nbsp;--&nbsp;&quot;$TEMP_PATH/Payload/&quot;*.app;echo&nbsp;&quot;$1&quot;)
#&nbsp;echo&nbsp;&quot;路径是:$TEMP_APP_PATH&quot;

#----------------------------------------
#&nbsp;2.&nbsp;将解压出来的.app拷贝进入工程下
#&nbsp;BUILT_PRODUCTS_DIR&nbsp;工程生成的APP包的路径
#&nbsp;TARGET_NAME&nbsp;target名称
TARGET_APP_PATH=&quot;$BUILT_PRODUCTS_DIR/$TARGET_NAME.app&quot;
echo&nbsp;&quot;app路径:$TARGET_APP_PATH&quot;

rm&nbsp;-rf&nbsp;&quot;$TARGET_APP_PATH&quot;
mkdir&nbsp;-p&nbsp;&quot;$TARGET_APP_PATH&quot;
cp&nbsp;-rf&nbsp;&quot;$TEMP_APP_PATH/&quot;&nbsp;&quot;$TARGET_APP_PATH&quot;

#----------------------------------------
#&nbsp;3.&nbsp;删除extension和WatchAPP.个人证书没法签名Extention
rm&nbsp;-rf&nbsp;&quot;$TARGET_APP_PATH/PlugIns&quot;
rm&nbsp;-rf&nbsp;&quot;$TARGET_APP_PATH/Watch&quot;

#----------------------------------------
#&nbsp;4.&nbsp;更新info.plist文件&nbsp;CFBundleIdentifier
#&nbsp;&nbsp;设置:&quot;Set&nbsp;:&nbsp;KEY&nbsp;Value&quot;&nbsp;&quot;目标文件路径&quot;
/usr/libexec/PlistBuddy&nbsp;-c&nbsp;&quot;Set&nbsp;:CFBundleIdentifier&nbsp;$PRODUCT_BUNDLE_IDENTIFIER&quot;&nbsp;&quot;$TARGET_APP_PATH/Info.plist&quot;
#----------------------------------------

#&nbsp;5.&nbsp;给MachO文件上执行权限
#&nbsp;拿到MachO文件的路径
APP_BINARY=`plutil&nbsp;-convert&nbsp;xml1&nbsp;-o&nbsp;-&nbsp;$TARGET_APP_PATH/Info.plist|grep&nbsp;-A1&nbsp;Exec|tail&nbsp;-n1|cut&nbsp;-f2&nbsp;-d\&gt;|cut&nbsp;-f1&nbsp;-d\&lt;`
#上可执行权限
chmod&nbsp;+x&nbsp;&quot;$TARGET_APP_PATH/$APP_BINARY&quot;

#----------------------------------------
#&nbsp;6.&nbsp;重签名第三方&nbsp;FrameWorks
TARGET_APP_FRAMEWORKS_PATH=&quot;$TARGET_APP_PATH/Frameworks&quot;
if&nbsp;[&nbsp;-d&nbsp;&quot;$TARGET_APP_FRAMEWORKS_PATH&quot;&nbsp;];
then
for&nbsp;FRAMEWORK&nbsp;in&nbsp;&quot;$TARGET_APP_FRAMEWORKS_PATH/&quot;*
do

#&nbsp;签名
/usr/bin/codesign&nbsp;--force&nbsp;--sign&nbsp;&quot;$EXPANDED_CODE_SIGN_IDENTITY&quot;&nbsp;&quot;$FRAMEWORK&quot;
done
fi复制代码</pre><h2 data-id="heading-11" style="box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">如何防止应用被重签名</h2><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">内容来源于「iOS安全防护之重签名防护和sysctl反调试」。</p><h3 data-id="heading-12" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">校验描述文件信息</h3><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);">可以在启动时校验描述文件信息与打包时是否一致。例如判断组织单位:<br style="box-sizing: border-box;"/>先记录证书中的组织单位信息。</p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p><figure style="box-sizing: border-box; margin: 0px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; font-size: 15px; white-space: normal; background-color: rgb(255, 255, 255);"><img src="http://api.cocoachina.com/uploads//20191211/1576049805655746.png" title="1576049805655746.png" alt="image.png" data-bd-imgshare-binded="1" data-isloading="1" style="box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 100%; display: block; margin: 0px auto;"/><figcaption style="box-sizing: border-box;"><br style="box-sizing: border-box;"/></figcaption></figure><span style="color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 15px; background-color: #FFFFFF;">在启动时检测是否一致。</span></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><br/></p><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">void&nbsp;&nbsp;checkCodesign(NSString&nbsp;*id){
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;描述文件路径
&nbsp;&nbsp;&nbsp;&nbsp;NSString&nbsp;*embeddedPath&nbsp;=&nbsp;[[NSBundle&nbsp;mainBundle]&nbsp;pathForResource:@&quot;embedded&quot;&nbsp;ofType:@&quot;mobileprovision&quot;];
&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;读取application-identifier&nbsp;&nbsp;注意描述文件的编码要使用:NSASCIIStringEncoding
&nbsp;&nbsp;&nbsp;&nbsp;NSString&nbsp;*embeddedProvisioning&nbsp;=&nbsp;[NSString&nbsp;stringWithContentsOfFile:embeddedPath&nbsp;encoding:NSASCIIStringEncoding&nbsp;error:nil];
&nbsp;&nbsp;&nbsp;&nbsp;NSArray&nbsp;*embeddedProvisioningLines&nbsp;=&nbsp;[embeddedProvisioning&nbsp;componentsSeparatedByCharactersInSet:[NSCharacterSet&nbsp;newlineCharacterSet]];
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;(int&nbsp;i&nbsp;=&nbsp;0;&nbsp;i&nbsp;&lt;&nbsp;embeddedProvisioningLines.count;&nbsp;i++)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;([embeddedProvisioningLines[i]&nbsp;rangeOfString:@&quot;application-identifier&quot;].location&nbsp;!=&nbsp;NSNotFound)&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSInteger&nbsp;fromPosition&nbsp;=&nbsp;[embeddedProvisioningLines[i+1]&nbsp;rangeOfString:@&quot;&quot;].location+8;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSInteger&nbsp;toPosition&nbsp;=&nbsp;[embeddedProvisioningLines[i+1]&nbsp;rangeOfString:@&quot;&quot;].location;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSRange&nbsp;range;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;range.location&nbsp;=&nbsp;fromPosition;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;range.length&nbsp;=&nbsp;toPosition&nbsp;-&nbsp;fromPosition;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSString&nbsp;*fullIdentifier&nbsp;=&nbsp;[embeddedProvisioningLines[i+1]&nbsp;substringWithRange:range];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSArray&nbsp;*identifierComponents&nbsp;=&nbsp;[fullIdentifier&nbsp;componentsSeparatedByString:@&quot;.&quot;];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NSString&nbsp;*appIdentifier&nbsp;=&nbsp;[identifierComponents&nbsp;firstObject];
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;对比签名ID
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(![appIdentifier&nbsp;isEqual:id])&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//exit
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;asm(
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;mov&nbsp;X0,#0\n&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;mov&nbsp;w16,#1\n&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;svc&nbsp;#0x80&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;}
}复制代码</pre><h3 data-id="heading-13" style="box-sizing: border-box; margin: 0px; font-size: 18px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">sysctl检测是否被调试</h3><pre style="box-sizing: border-box; padding: 18px 15px 12px; margin-top: 0px; margin-bottom: 10px; font-size: 13px; line-height: 1.42857; color: rgb(177, 177, 177); word-break: break-all; overflow-wrap: break-word; border: 1px solid rgb(204, 204, 204); border-radius: 4px; overflow: scroll auto; position: relative; width: 749px;">#import&nbsp;bool&nbsp;checkDebugger(){
&nbsp;&nbsp;&nbsp;&nbsp;//控制码
&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;name[4];//放字节码-查询信息
&nbsp;&nbsp;&nbsp;&nbsp;name[0]&nbsp;=&nbsp;CTL_KERN;//内核查看
&nbsp;&nbsp;&nbsp;&nbsp;name[1]&nbsp;=&nbsp;KERN_PROC;//查询进程
&nbsp;&nbsp;&nbsp;&nbsp;name[2]&nbsp;=&nbsp;KERN_PROC_PID;&nbsp;//通过进程id查进程
&nbsp;&nbsp;&nbsp;&nbsp;name[3]&nbsp;=&nbsp;getpid();//拿到自己进程的id
&nbsp;&nbsp;&nbsp;&nbsp;//查询结果
&nbsp;&nbsp;&nbsp;&nbsp;struct&nbsp;kinfo_proc&nbsp;info;//进程查询信息结果
&nbsp;&nbsp;&nbsp;&nbsp;size_t&nbsp;info_size&nbsp;=&nbsp;sizeof(info);//结构体大小
&nbsp;&nbsp;&nbsp;&nbsp;int&nbsp;error&nbsp;=&nbsp;sysctl(name,&nbsp;sizeof(name)/sizeof(*name),&nbsp;&amp;info,&nbsp;&amp;info_size,&nbsp;0,&nbsp;0);
&nbsp;&nbsp;&nbsp;&nbsp;assert(error&nbsp;==&nbsp;0);//0就是没有错误
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;//结果解析&nbsp;p_flag的第12位为1就是有调试
&nbsp;&nbsp;&nbsp;&nbsp;//p_flag&nbsp;与&nbsp;P_TRACED&nbsp;=0&nbsp;就是有调试
&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;((info.kp_proc.p_flag&nbsp;&amp;&nbsp;P_TRACED)&nbsp;!=0);
&nbsp;&nbsp;&nbsp;
}
...
...
//检测异常时退出
if&nbsp;(checkDebugger())&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;asm(&quot;mov&nbsp;X0,#0\n&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;mov&nbsp;w16,#1\n&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;svc&nbsp;#0x80&quot;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;}
...复制代码</pre><h2 data-id="heading-14" style="box-sizing: border-box; font-size: 24px; color: rgb(42, 42, 42); font-family: PingFangSC-Regular, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);">参考链接</h2><p style="box-sizing: border-box; margin-top: 15px; margin-bottom: 15px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; color: rgb(42, 42, 42); line-height: 30px; overflow-wrap: break-word; white-space: normal; background-color: rgb(255, 255, 255);"><a target="_blank" href="http://blog.cnbang.net/tech/3386/" rel="nofollow noopener noreferrer" style="box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;">iOS App 签名的原理</a><br style="box-sizing: border-box;"/><a target="_blank" href="https://juejin.im/post/5c7e796351882532cd57adc4" rel="" style="box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;">iOS逆向(3)-APP重签名</a><br style="box-sizing: border-box;"/><a target="_blank" href="https://www.jianshu.com/p/248d3d2c323c" rel="nofollow noopener noreferrer" style="box-sizing: border-box; background-color: transparent; color: rgb(82, 192, 246); text-decoration-line: none; margin: 0px 0px 4px; padding: 0px; border: 0px; outline: 0px; list-style: none; display: inline-block;">iOS安全防护之重签名防护和sysctl反调试</a></p><p><span style="color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;">本文来自</span><a href="https://juejin.im/post/5de4acc7518825766e7a8489" style="box-sizing: border-box; background-color: rgb(255, 255, 255); color: rgb(42, 42, 42); margin: 0px; padding: 0px; border: 0px; outline: 0px; list-style: none; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; white-space: normal;">&nbsp;juejin&nbsp;</a><span style="color: #2A2A2A; font-family: PingFangSC-Regular, sans-serif; font-size: 16px; background-color: #FFFFFF;">，作者 SimonYe</span></p>                </div>
                                
              
					<div class="recommend-post pt30 mt40 mb30 border-top">
                        <div class="row">
                            <div class="col-md-8">
                                <h4 class="mt0">你可能感兴趣的文章</h4>
                                <ul class="widget-links list-unstyled">
									<ul class="widget-links list-unstyled">
																										</ul>
                            </div>
                            <div class="col-md-4"></div>
                        </div>
                    </div>
										<h2 class="h4 post-comment-title">评论区</h2>
					<div style="margin-top:-40px; ">
					<label id="AjaxCommentBegin"></label>
<div id="comments">	
	<span class="icon" title="comment"></span>

		<!--评论框-->
		
<div class="commentpost" id="comment">
    <h4> 发表评论 <span><a rel="nofollow" id="cancel-reply" href="#comment" style="display:none;"><small>取消回复</small></a></span></h4>
	<form id="frmSumbit" target="_self" method="post" action="http://suwenclub.cn/zb_system/cmd.php?act=cmt&amp;postid=21&amp;key=b95b91c650ce4840bc1e36db8c6445f4" >
	<input type="hidden" name="inpId" id="inpId" value="21" />
	<input type="hidden" name="inpRevID" id="inpRevID" value="0" />
	<p><label for="name">名 称</label><input type="text" name="inpName" id="inpName" class="text" value="访客" size="28" tabindex="1" /><font color="#ff6f3d">必填</font></p>
	<p><label for="email">邮 箱</label><input type="text" name="inpEmail" id="inpEmail" class="replytext text" value="" size="28" tabindex="2" placeholder="" />选填</p>
	<p><label for="homepage">网 址</label><input type="text" name="inpHomePage" id="inpHomePage" class="replytext text" value="" size="28" tabindex="3" placeholder="" />选填</p>
	<p><textarea name="txaArticle" id="txaArticle" class="textarea text" cols="50" rows="4" tabindex="5" placeholder="任何广告行为都会被封杀~" ></textarea></p>
	<p><input name="sumbit" type="submit" tabindex="6" value="提交" onclick="return VerifyMessage()" class="button" />◎欢迎参与讨论，请在这里发表您的看法、交流您的观点。</p>
	</form>
</div>	</div>
<label id="AjaxCommentEnd"></label></div>
					
            </div><!-- /.main -->

            <div class="col-xs-12 col-md-3 side">
                
                
											
<div class="widget-box">
					<h2 class="h4 widget-box__title">热门文章</h2>
					<ul class="list-unstyled list-unstyled ">
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=23">
									<img class="media-object avatar-40" src="http://suwenclub.cn/zb_users/theme/ydgreen/style/images/pic.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=23" title="头条 穿山甲广告 错误码列表">头条 穿山甲广告 错误码列表</a></strong>
									<p class="text-muted">阅读: 8105 评论:1</p>
								</div>
							</li>
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=18">
									<img class="media-object avatar-40" src="//upload-images.jianshu.io/upload_images/1176193-bb0898342e0a09d6.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=18" title="Xcode11 打包IPA上传App Store失败解决办法 xcrun altool密钥上传">Xcode11 打包IPA上传App Store失败解决办法 xcrun altool密钥上传</a></strong>
									<p class="text-muted">阅读: 2231 </p>
								</div>
							</li>
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=21">
									<img class="media-object avatar-40" src="http://api.cocoachina.com/uploads//20191211/1576049725126335.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=21" title="iOS证书签名机制&amp;重签名&amp;防止重签名">iOS证书签名机制&amp;重签名&amp;防止重签名</a></strong>
									<p class="text-muted">阅读: 1646 </p>
								</div>
							</li>
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=6">
									<img class="media-object avatar-40" src="http://suwenclub.cn/zb_users/theme/ydgreen/style/images/pic.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=6" title="动手制作一个简易的iOS动态执行器">动手制作一个简易的iOS动态执行器</a></strong>
									<p class="text-muted">阅读: 1449 </p>
								</div>
							</li>
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=20">
									<img class="media-object avatar-40" src="http://suwenclub.cn/zb_users/theme/ydgreen/style/images/pic.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=20" title="CocoaPods指定版本号带~&gt;与不带的区别">CocoaPods指定版本号带~&gt;与不带的区别</a></strong>
									<p class="text-muted">阅读: 1199 </p>
								</div>
							</li>
	<li class="widget-user media">
								
								<a class="pull-left" href="http://suwenclub.cn/?id=25">
									<img class="media-object avatar-40" src="http://suwenclub.cn/zb_users/theme/ydgreen/style/images/pic.png"/>
								</a>
								
								<div class="media-object">
									<strong><a href="http://suwenclub.cn/?id=25" title="Quick tip: clearing your app’s launch screen cache on iOS">Quick tip: clearing your app’s launch screen cache on iOS</a></strong>
									<p class="text-muted">阅读: 1085 </p>
								</div>
							</li>
					</ul>
				</div>										
	<div class="side-ask alert alert-warning  article__writing">
<p><span class="cp-hello">您好，欢迎到访网站！</span><br/><span class="cp-login"><a href="http://suwenclub.cn/zb_system/cmd.php?act=login">登录后台</a></span>&nbsp;&nbsp;<span class="cp-vrs"><a href="http://suwenclub.cn/zb_system/cmd.php?act=misc&amp;type=vrs">查看权限</a></span></p>
</div>
	
		<div class="side-ask widget_divCalendar_inner alert alert-warning  article__writing">
	<p><table id="tbCalendar">
    <caption><a href="http://suwenclub.cn/?date=2020-1">«</a>&nbsp;&nbsp;&nbsp;<a href="http://suwenclub.cn/?date=2020-2">2020年2月</a>&nbsp;&nbsp;&nbsp;<a href="http://suwenclub.cn/?date=2020-3">»</a></caption>
    <thead><tr> <th title="星期一" scope="col"><small>一</small></th> <th title="星期二" scope="col"><small>二</small></th> <th title="星期三" scope="col"><small>三</small></th> <th title="星期四" scope="col"><small>四</small></th> <th title="星期五" scope="col"><small>五</small></th> <th title="星期六" scope="col"><small>六</small></th> <th title="星期日" scope="col"><small>日</small></th></tr></thead>
    <tbody>
    <tr>
<td class="pad" colspan="5"></td><td>1</td><td>2</td></tr><tr><td>3</td><td>4</td><td>5</td><td>6</td><td>7</td><td>8</td><td>9</td></tr><tr><td>10</td><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td><td>16</td></tr><tr><td>17</td><td>18</td><td>19</td><td>20</td><td>21</td><td>22</td><td>23</td></tr><tr><td>24</td><td>25</td><td>26</td><td>27</td><td>28</td><td>29</td>	</tr></tbody>
</table></p>
	</div>
	
<div class="widget-box ">
		<h2 class="h4 widget-box__title">标签列表</h2>
	
			<ul class="taglist--inline multi"><li class="tagPopup"><a class="tag" href="http://suwenclub.cn/?tags=1" title="移动开发">移动开发</a></li><li class="tagPopup"><a class="tag" href="http://suwenclub.cn/?tags=2" title="Flutter">Flutter</a></li></ul>
	</div>

<div class="widget-box ">
		<h2 class="h4 widget-box__title">最新留言</h2>
	
			<ul class="widget-links list-unstyled"><li class="widget-links__item"><small class="text-muted">访客说: </small><a title="" href="http://suwenclub.cn/?id=23#cmt1">我想问一下，错误码108的情况该怎么优化</a></li></ul>
	</div>
								
            </div><!-- /.side -->
        </div>
    </div>
</div>
<div id="fixedTools" class="hidden-xs hidden-sm">
    <a id="backtop" class="hidden border-bottom" href="#">回顶部</a>

    <div class="qrcodeWraper">
        <a><span class="glyphicon glyphicon-qrcode"></span></a>
        <img id="qrcode" class="border" alt="sf-wechat" src="http://suwenclub.cn/zb_users/theme/ydgreen/style/img/weixin.png">

        <p class="qrcode-text">扫扫关注微信</p>
    </div>
</div>
<footer id="footer">
    <div class="container">
	
        <div class="copyright">
            Copyright 素问 Rights Reserved.<br>
			<!-- //请尊重别人的辛苦，不要删除theme by代码，如需要删除请联系QQ525887672付费20元删除，这20元也可作为购买本人其它付费主题代金使用，本人其它付费主题：https://app.zblogcn.com/?auth=5670 -->
			Power by <a href="http://www.zblogcn.com/" rel="nofollow" target="_blank">Z-blogPHP</a>
theme by <a href="http://www.ylefu.com/" target="_blank">zblog模板</a><br /><a href="https://beian.miit.gov.cn">皖ICP备17003059号-1</a>
<a href="https://beian.miit.gov.cn">皖ICP备17003059号-2</a>
<a href="https://beian.miit.gov.cn">皖ICP备17003059号-3</a> </div></div></footer>
</body>
<script>
(function(w){w.SF={staticUrl:""};w.SF.token=(function(){var _LsI6GQ=''+'qAx'+'4'+'2'+'254'+'d8'+'261'+'94'+''+'f9'+'Arb'+'d'+'d'+'5a'+'e8'+'f4f'+'85'+'4'+'bf'+'882'+''+''+'d',_omneLe=[[0,3],[14,17]];for(var i=0;i<_omneLe.length;i++){_LsI6GQ=_LsI6GQ.substring(0,_omneLe[i][0])+_LsI6GQ.substring(_omneLe[i][1])}return _LsI6GQ})()})(window);var lock={type:"",text:'',table:{"ban_post":[1,""]}};
</script>
<script crossorigin src="http://suwenclub.cn/zb_users/theme/ydgreen/style/js/assets.js"></script>
<script crossorigin src="http://suwenclub.cn/zb_users/theme/ydgreen/style/js/index.js"></script>
</html>
<!--146.14 ms , 11 query , 2294kb memory , 0 error-->